//
//  ViewController.m
//  02_UIViewcontroller
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIView *subView;
@end

@implementation ViewController
// ViewController的声明周期
// 初始化方法
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // 不要在这个方法中去加载视图
        // 在这个方法中去初始化一些数据相关的内容
    }
    return self;
}
// loadView 加载UIViewController中的View
// UINavigation UITableView 在loadView中重写赋值了
- (void) loadView {
    [super loadView];
    // 改变self.view
}
// View 已经加载
// 去做所有自定义的视图的创建
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //[self creatButton];
    
 }
- (void)creatButton {
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor = [UIColor cyanColor];
    btn.frame = CGRectMake(100, 50, 100, 50);
    [self.view addSubview:btn];
    
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    PresentViewController *present = [[PresentViewController alloc] init];
    // 模态出一个视图控制器
    [self presentViewController:present animated:YES completion:nil];
    // 模态 动画效果
    // UIModalTransitionStyleCrossDissolve 渐变
    // UIModalTransitionStyleFlipHorizontal 左右旋转
    // UIModalTransitionStyleCoverVertical 默认
    // UIModalTransitionStylePartialCurl 翻书
    present.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
// 注意:init loadView viewDidLoad 只执行一次
// 下诉方法为会执行多次的
// 视图将要出现时
- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
// 视图已经出现时
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
// 视图将要消失时
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
// 视图已经消失时
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
//// 懒加载
//- (UIView *)subView {
//    if (_subView == nil) {
//        _subView = [[UIView alloc] init];
//    }
//    return _subView;
//}

// 接收到内存警告时执行的方法
- (void)didReceiveMemoryWarning {
    // 从父类继承来的内存警告的打印
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    // 释放部分内存资源
    // 把未显示在屏幕上的资源置空
}

@end
